import { ref, onMounted } from 'vue'
export function useDefer() {
  const frameCount = ref(0)
  let rafId: number
  function updateFrameCount() {
    rafId = requestAnimationFrame(() => {
      frameCount.value++
      updateFrameCount()
    })
  }
  updateFrameCount()

  return function defer(n: number) {
    return frameCount.value >= n
  }
}
